package hust.music.action;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import hust.music.action.base.ActionBase;
import hust.music.service.PlayListModService;
import hust.music.util.DynamicInfo;
import java.util.*;

/**
 * SearchAction
 * 
 * @author Txazo
 * @since 1.0
 */
@Controller
@Scope("session")
public class SearchAction extends ActionBase {

	private static final long serialVersionUID = 1L;

	/** 搜索关键字 */
	private String title;
	/** 搜索音乐 */
	private List<DynamicInfo> music = new ArrayList<DynamicInfo>();
	/** 搜索流派集 */
	private List<DynamicInfo> playList = new ArrayList<DynamicInfo>();

	@Autowired
	private PlayListModService playListPageModService;

	/**
	 * 搜索音乐和流派集
	 * 
	 * @return 逻辑视图
	 */
	public String search() {
		if (title == null || title.equals("") || title.equals("请输入关键字搜索")) {
			title = "请输入搜索关键字";
		} else {
			music = playListPageModService.searchMusic(title);

			playList = playListPageModService.searchPlayList(title);
		}

		return SUCCESS;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public List<DynamicInfo> getMusic() {
		return music;
	}

	public void setMusic(List<DynamicInfo> music) {
		this.music = music;
	}

	public List<DynamicInfo> getPlayList() {
		return playList;
	}

	public void setPlayList(List<DynamicInfo> playList) {
		this.playList = playList;
	}

}
